/*------------------------------------------------------
                hou_elearningGEN beta v1.0
Author: xtrung.net@gmail.com
Write On: 04/27/2008
Create On:4/13/2012 11:23:01 AM
------------------------------------------------------*/
using hou_elearning.DataAccess.Base;
using hou_elearning.Entity;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
using System.Collections;
using System.Web;

namespace hou_elearning.DataAccess
{    
    public class BaikiemtratracnghiemDAL : SqlProvider<BaikiemtratracnghiemEntity>
    {
        static BaikiemtratracnghiemDAL()
        {
            InitReader();
        }
        protected static void InitReader()
        {
            getFromReader=delegate(SqlDataReader dr)
            {
                BaikiemtratracnghiemEntity entity = new BaikiemtratracnghiemEntity();
				entity.FK_iThongtinbaikiemtraID = Int64.Parse("0"+dr["FK_iThongtinbaikiemtraID"].ToString());
				entity.FK_iPhuonganID = Int64.Parse("0"+dr["FK_iPhuonganID"].ToString());
                return entity;
            };
        }
        public static BaikiemtratracnghiemEntity GetOne(Int64 FK_iThongtinbaikiemtraID)
        {
            string cmdName = "spBaikiemtratracnghiem_GetByPK";
            SqlParameter p = new SqlParameter("@FK_iThongtinbaikiemtraID", FK_iThongtinbaikiemtraID);
            BaikiemtratracnghiemEntity entity = GetOne(cmdName, p);
            return entity;
        }
        public static List<BaikiemtratracnghiemEntity> GetAll()
        {
            string cmdName = "spBaikiemtratracnghiem_Get";
            return GetList(cmdName);
        }
        
        public static int Add(BaikiemtratracnghiemEntity entity)
        {
            string cmdName = "spBaikiemtratracnghiem_Insert";
            return Run(cmdName,true,initParams(entity));

        }
        public static bool Edit(BaikiemtratracnghiemEntity entity)
        {
            string cmdName = "spBaikiemtratracnghiem_Update";
            return Run(cmdName,false,initParams(entity))>0;
        }
        public static bool Remove(Int64 FK_iThongtinbaikiemtraID)
        {
            string cmdName = "spBaikiemtratracnghiem_Delete";
            SqlParameter p = new SqlParameter("@FK_iThongtinbaikiemtraID", FK_iThongtinbaikiemtraID);
            return Run(cmdName,false,p)>0;
        }
        #region private
        private static SqlParameter[] initParams(BaikiemtratracnghiemEntity entity)
        {
            SqlParameter[] p = new SqlParameter[2];
			p[0] = new SqlParameter("@FK_iThongtinbaikiemtraID", entity.FK_iThongtinbaikiemtraID);
			p[1] = new SqlParameter("@FK_iPhuonganID", entity.FK_iPhuonganID);
            return p;
        }
        #endregion
       
    }
}